// pages/service/service.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    openid:'',
    nicheng:'',
    email:'',
    mobile_phone:'',
    weixin:'',
    weibo:'',
    address: ''

  },

  /**
   * 生命周期函数--监听页面加载
   */
  hold:function(){
    var that = this;
    console.log(that.data.nicheng)
    console.log(that.data.email)
    console.log(that.data.mobile_phone)
    console.log(that.data.weixin)
    console.log(that.data.weibo)
    console.log(that.data.address)
    wx.request({
      url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=xiugaixinxi',
      data:{
        openid: app.globalData.opid,
        nicheng: that.data.nicheng,
        email:that.data.email,
       mobile: that.data.mobile_phone,
        weixin:that.data.weixin,
        weibo:that.data.weibo,
        address:that.data.address,
      },
      success:function(res){
       
        if (res.data.success == 1){
          console.log(res)

          wx.showToast({
            title: '修改成功',
            mask: true,
            duration: 2000,
            icon: 'success'
          })

          wx.switchTab({
            url: '../index/index'
          })
        }
      }
    })
  },
  onLoad: function (options) {
   var that = this;
   that.setData({
     openid: app.globalData.opid
   })
   wx.request({
     url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=huiyuanxinxi',
     data:{
       openid: app.globalData.opid
     },
     success:function(res){
       console.log(res)
       that.setData({
         nicheng: res.data.nicheng,
         email: res.data.email,
         mobile_phone: res.data.mobile_phone,
         weixin: res.data.weixin,
         weibo: res.data.weibo,
         address: res.data.address
       })
     }
   })
  },
  changeinput:function(e){
    var name = e.target.dataset.name ;
    var obj  = {};
    obj[name] = e.detail.value;
    this.setData(obj)
    console.log(this.data.nicheng)
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})